package chixing.day03;


import java.util.Arrays;

public class Sort2Demo {
    public static void main(String[] args) {
        int[] array1 = {15,48,59,11,25,44};
        int[] array2 = {15,48,59,11,25,44};
        int[] newarray = insertSort(array1,array2);
    }
    public static void bubboSort(int[] a){
        int temp;
        for (int i = 0;i < a.length ;i++){
            for (int j = 0;j < a.length - i - 1;j++){
                if (a[j] > a[j + 1]){
                    temp=a[j];
                    a[j]=a[j+1];
                    a[j+1]=temp;
                }
            }
        }
    }

    public static int[] insertSort(int[] a,int[] b){
        int[] c = new int[a.length + b.length];
        c[0] = a[0];
        int index = 0;//c数组中已有元素的下标
        //循环遍历a数组中的元素
        for (int i = 1;i < a.length;i++){
            //循环遍历c数组中已经存在的元素
            for (int j = index;j <= 0;j--){
                if (a[i] < c[j]){
                    c[j+1] = c[j];
                }else {
                    c[j+1] = a[i];
                    index++;
                }
            }
            c[0] = a[i];
            index++;
        }
        return c;
    }

}
